/**
 * Auto gen via dbpojo-gen.
 */
package com.us.usws.site.console.action;

import javax.inject.Inject;

import org.apache.commons.lang3.StringUtils;

import com.us.usws.model.domain.video.VideoComment;
import com.us.usws.service.cud.VideoCommentCUDService;
import com.us.usws.service.ro.VideoCommentROService;
import com.us.usws.support.uitls.DataPageUtil;
import com.us.usws.support.uitls.JSONDataUtil;
import com.us.usws.support.uitls.Order;

/**
 * Struts2 action
 * @author robot
 */
public class VideoCommentAction extends BasePageSearchAction<VideoComment> {

	private static final long serialVersionUID = 1L;

	private VideoComment videoComment;

	@Inject
	private VideoCommentROService videoCommentROService;

	@Inject
	private VideoCommentCUDService videoCommentCUDService;

	private String uids;

	/**
	 * ajax load the list of VideoComment
	 */
	public void ajaxLoadVideoComments() {
		createDataPageUtil();
		dataPageUtil.setOrder(Order.desc("create_date"));
		videoCommentROService.loadVideoCommentsByPage(dataPageUtil);
		getOut().println(JSONDataUtil.extJsonSupportPage(dataPageUtil.getResult(), dataPageUtil.getRowCount()));
	}

	/**
	 * ajax update VideoComment
	 */
	public void ajaxUpdateVideoComment() {
		if (videoComment != null) {
			String uid = videoComment.getUid();
			if (StringUtils.isNotBlank(uid)) {
				videoCommentCUDService.updateVideoComment(videoComment);
			} else {
				videoCommentCUDService.addVideoComment(videoComment);
			}
			getOut().print(true);
		} else {
			getOut().print(false);
		}
	}

	/**
	 * ajax delete user.
	 */
	public void ajaxDeleteVideoComment() {
		videoCommentCUDService.deleteVideoCommentMore(uids);
	}
	
	public void setVideoComment(VideoComment videoComment) {
		this.videoComment = videoComment;
	}

	public VideoComment getVideoComment() {
		return videoComment;
	}

	public DataPageUtil<VideoComment> getDataPageUtil() {
		return dataPageUtil;
	}

	public void setDataPageUtil(DataPageUtil<VideoComment> dataPageUtil) {
		this.dataPageUtil = dataPageUtil;
	}

	public String getUids() {
		return uids;
	}

	public void setUids(String uids) {
		this.uids = uids;
	}

}